const Service = require('../../../core/service/ApiService');

class AccountDao extends Service {

    //登录
    async findAccountByAccount(account) {
        const sql = `select account,pwd,town.name as town_name
                    from admin
                    inner join town on admin.town_id = town.town_id
                    where account = '${account}'
                    and status = ${this.constant.ADMIN_STATUS.ENABLE}`;
        const result = await this.model.query(sql, {type: this.model.QueryTypes.SELECT});
        return result.length === 0 ? null : result[0];

    }


    //获取小区列表
    async getSubList() {
        return this.model.Subdistrict.findAll({
            attributes: ['subdistrict_id', 'name', 'icon'],
            raw: true
        })
    }
}

module.exports = AccountDao;
